using Headsight.BPMN2WF.BPMN.Schemas;
using Headsight.BPMN2WF.Testing.TestObjCtors;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Headsight.BPMN2WF.BPMN.Model
{
    [TestClass]
    public class BPMNProcessFactoryBPMNSequenceFlowTest
    {
        private BPMNSequenceFlowFactory _sut;
        private BPMNProcessFactoryParams _bpmnMFacParams;
        private tProcessCtor _tProcessCtor;
        private tSequenceFlow _tSeqFlow1;
        private tSequenceFlow _tSeqFlow2;

        [TestInitialize]
        public void SetUp()
        {
            _tSeqFlow1 = new tSequenceFlowCtor().Create();
            _tSeqFlow2 = new tSequenceFlowCtor().Create();

            _tProcessCtor = new tProcessCtor();
            _bpmnMFacParams = new BPMNModelFactoryParamsCtor().Create();

            _sut = new BPMNSequenceFlowFactoryImpl();
        }

        private void PerformTestBPMNSequenceFlows(params tSequenceFlow[] tSequenceFlows)
        {
            var tProcess = _tProcessCtor.With(tSequenceFlows).Create();
            var actual = _sut.CreateBPMNSequenceFlows(tProcess, _bpmnMFacParams);

            Assert.AreEqual(tSequenceFlows.Length, actual.Count);

            for (var i = 0; i < tSequenceFlows.Length; i++)
            {
                Assert.AreSame(tSequenceFlows[i], actual[i].TElement);
            }
        }

        [TestMethod]
        public void CreateBPMNSequenceFlows_in_case_of_0_tSequenceFlows()
        {
            PerformTestBPMNSequenceFlows();
        }

        [TestMethod]
        public void CreateBPMNSequenceFlows_in_case_of_1_tSequenceFlows()
        {
            PerformTestBPMNSequenceFlows(_tSeqFlow1);
        }

        [TestMethod]
        public void CreateBPMNSequenceFlows_in_case_of_2_tSequenceFlows()
        {
            PerformTestBPMNSequenceFlows(_tSeqFlow1, _tSeqFlow2);
        }
    }
}